using System;
using System.Data;

namespace LantixLBSServer.Web.DbAccess.Helper
{
    /// <summary>
    /// Interface of database helper
    /// </summary>
    public interface IDbHelper : IDisposable
    {
        /// <summary>
        /// connection 
        /// </summary>
        IDbConnection Connection { get; }

        /// <summary>
        /// command parameter list
        /// </summary>
        IDataParameterCollection Parameters { get; }

        /// <summary>
        /// Add output parameter to command
        /// </summary>
        /// <param name="paramName"></param>
        void AddOutputParameter(string paramName);

        /// <summary>
        /// Add output parameter to command
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramType"></param>
        /// <param name="size"></param>
        void AddOutputParameter(string paramName, System.Data.DbType paramType, int size);

        /// <summary>
        /// Add output parameter to command
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramType"></param>
        void AddOutputParameter(string paramName, System.Data.DbType paramType);

        /// <summary>
        /// Add parameter to command
        /// </summary>
        /// <param name="paramName"></param>      
        void AddParameter(string paramName);

        /// <summary>
        /// Add parameter to command
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        void AddParameter(string paramName, DateTime paramValue);

        /// <summary>
        /// Add a parameter to command
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        void AddParameter(string paramName, object paramValue);

        /// <summary>
        /// Add a parameter to command
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        /// <param name="dbType"></param>
        void AddParameter(string paramName, object paramValue, System.Data.DbType dbType);

        /// <summary>
        /// Add return parameter to command
        /// </summary>
        /// <param name="paramName"></param>
        void AddReturnParameter(string paramName);
        
        /// <summary>
        /// get parameter value
        /// </summary>
        /// <param name="paramName"></param>
        /// <returns></returns>
        object GetParameterValue(string paramName);

        /// <summary>
        /// set parameter value
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        void SetParameterValue(string paramName, DateTime paramValue);

        /// <summary>
        /// set parameter value
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        void SetParameterValue(string paramName, object paramValue);

        /// <summary>
        /// clear parameters
        /// </summary>
        void ClearParameter();

        /// <summary>
        /// open connection
        /// </summary>
        void OpenConnection();

        /// <summary>
        /// close connection
        /// </summary>
        void CloseConnection();

        /// <summary>
        /// Execute command and retur a data reader
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        IDataReader ExecuteDataReader(string commandText);

        /// <summary>
        /// Execute command and retur a data reader
        /// </summary>
        /// <param name="commandText"></param>
        /// <param name="isProcedure"></param>
        /// <returns></returns>
        IDataReader ExecuteDataReader(string commandText, bool isProcedure);
        
        /// <summary>
        /// Execute command and retur a DataSet
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        DataSet ExecuteDataSet(string commandText);

        /// <summary>
        /// Execute command and retur a DataSet
        /// </summary>
        /// <param name="commandText"></param>
        /// <param name="isProcedure"></param>
        /// <returns></returns>
        DataSet ExecuteDataSet(string commandText, bool isProcedure);

        /// <summary>
        /// Execute command and retur the first DataTable of the DataSet
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        DataTable ExecuteDataTable(string commandText);

        DataTable ExecuteDataTable(string commandText, int pageIndex, int pageSize);

        /// <summary>
        /// Execute command and retur the first DataTable of the DataSet
        /// </summary>
        /// <param name="commandText"></param>
        /// <param name="isProcedure"></param>
        /// <returns></returns>
        DataTable ExecuteDataTable(string commandText, bool isProcedure);

        DataTable ExecuteDataTable(string commandText, bool isProcedure, int pageIndex, int pageSize);

        /// <summary>
        /// Execute command and return the count of effect rows
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        int ExecuteNonQuery(string commandText);

        /// <summary>
        /// Execute command and return the count of effect rows
        /// </summary>
        /// <param name="commandText"></param>
        /// <param name="isProcedure"></param>
        /// <returns></returns>
        int ExecuteNonQuery(string commandText, bool isProcedure);

        /// <summary>
        /// Execute command and return the count of effect rows
        /// </summary>
        /// <param name="commandText"></param>
        /// <param name="isProcedure"></param>
        /// <param name="closeConnection"></param>
        /// <returns></returns>
        int ExecuteNonQuery(string commandText, bool isProcedure, bool closeConnection);
        
        /// <summary>
        /// Executes the query, and returns the first column of the first row in the resultset
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        object ExecuteScalar(string commandText);

        /// <summary>
        /// Executes the query, and returns the first column of the first row in the resultset
        /// </summary>
        /// <param name="commandText"></param>
        /// <param name="isProcedure"></param>
        /// <returns></returns>
        object ExecuteScalar(string commandText, bool isProcedure);                        

        

    }
}
